<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="common/css_js.jsp"></jsp:include>
<%
    String path=request.getContextPath();
%>
<html>
<head>
    <title>Title</title>
</head>
<%-- 导入窗口插件 --%>
<script src="<%=path%>/static/jquery/jquery-3.6.0.min.js"></script>
<script src="<%=path%>/static/hui/lib/layer/2.4/layer.js"></script>
<script src="<%=path%>/static/js/common.js"></script>
<body>

<div class="container" style="margin-top: 10px">
    <div class="m-3">
            <div class="input-group mb-3 float-right">
                <a class="btn btn-success mr-3" id="add" href="javascript:" onclick="layer_show('添加管理员','addAdmin',600,500)">添加</a>
            </div>
    </div>
    <table class="table">
        <thead>
        <tr>
            <td>ID</td>
            <td>姓名</td>
            <td>性别</td>
            <td>账号</td>
            <td>密码</td>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${pageData.list}" var="one">
            <tr>
                <td>${one.a_id}</td>
                <td>${one.a_name}</td>
                <td>${one.a_sex}</td>
                <td>${one.a_username}</td>
                <td>${one.a_password}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div class="container">
        <div class="col-md-6 offset-md-3">
            <div class="center-align">
                <div id="page">
                    <button class="btn btn-secondary" onclick="firstPage()">首页</button>
                    <button class="btn btn-secondary" onclick="prevPage()">上一页</button>
                    <button class="btn btn-secondary" onclick="nextPage()">下一页</button>
                    <button class="btn btn-secondary" onclick="lastPage()">尾页</button>
                    <span>当前第${pageData.currentPage}页，共${pageData.totalPage}页，共${pageData.totalSize}条记录</span>
                </div>
            </div>
        </div>
    </div>
    <script>
        var pageSize = ${pageData.pageSize};
        var pageNumber = ${pageData.currentPage};
        var totalPage = ${pageData.totalPage};

        function firstPage() {
            if (pageNumber != 1) {
                pageNumber = 1;
                gotoPage();
            }
        }

        function prevPage() {
            if (pageNumber > 1) {
                pageNumber--;
                gotoPage();
            }
        }

        function nextPage() {
            if (pageNumber < totalPage) {
                pageNumber++;
                gotoPage();
            }
        }

        function lastPage() {
            if (pageNumber != totalPage) {
                pageNumber = totalPage;
                gotoPage();
            }
        }

        function gotoPage() {
            window.location.href = "${pageContext.request.contextPath}/admin/queryAllAdmin?pageSize=" + pageSize + "&pageNumber=" + pageNumber;
        }
    </script>
</div>
</body>
</html>
